﻿<dx:DXWindow x:Class="SQLQuery.MainWindow"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="RibbonMainWindow" xmlns:dxr="clr-namespace:DevExpress.Xpf.Ribbon;assembly=DevExpress.Xpf.Ribbon.v11.1" 
        xmlns:dxb="clr-namespace:DevExpress.Xpf.Bars;assembly=DevExpress.Xpf.Core.v11.1"
        xmlns:dxd="clr-namespace:DevExpress.Xpf.Docking;assembly=DevExpress.Xpf.Docking.v11.1"  
        xmlns:dx="clr-namespace:DevExpress.Xpf.Core;assembly=DevExpress.Xpf.Core.v11.1"
        xmlns:local="clr-namespace:SQLQuery.ViewModel"
        xmlns:ui="clr-namespace:SQLQuery.UI" 
        WindowStartupLocation="CenterScreen" 
         Icon="/SQLQuery;component/Images/logo2.ico" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <dx:DXWindow.Resources>
        <RoutedUICommand Text="格式刷" x:Key="txtFormat"/>
        <RoutedUICommand Text="复制" x:Key="copyFieldName"/>
        <RoutedUICommand Text="保存" x:Key="fileSave"/>
        <RoutedUICommand Text="运行" x:Key="runSQL"/>
    </dx:DXWindow.Resources>
    <dx:DXWindow.InputBindings>
        <KeyBinding Modifiers="Ctrl" Key="C" Command="{StaticResource copyFieldName}"/>
    </dx:DXWindow.InputBindings>
    <dx:DXWindow.CommandBindings>
        <CommandBinding Command="{StaticResource txtFormat}" CanExecute="TxtFormat_CommandBinding_CanExecute" Executed="TxtFormat_CommandBinding_Executed"/>
        <CommandBinding Command="{StaticResource copyFieldName}" Executed="CopyFieldName_CommandBinding_Executed"/>
        <CommandBinding Command="{StaticResource runSQL}" Executed="RunSQL_CommandBinding_Executed" CanExecute="RunSQL_CommandBinding_CanExecute"/>

    </dx:DXWindow.CommandBindings>

    <Grid>
        <dxb:BarManager Name="barManager1">
            <dxb:BarManager.Items>
                <dxb:BarButtonItem Name="dbcreate" Content="新建数据源" Command="{Binding ViewModel.CreateDBCommand}" Glyph="/QueryResource;component/Images/Tool/Add_32x32.png"/>
              
                <dxb:BarButtonItem Name="fileopen" Content="打开" KeyGesture="Ctrl+O" Command="{Binding ViewModel.FileOpenCommand}" Glyph="/QueryResource;component/Images/Tool/open-32x32.png" />
                <dxb:BarButtonItem Name="filesave" Content="另存为" KeyGesture="Ctrl+S" Command="{StaticResource fileSave}" Glyph="/QueryResource;component/Images/Tool/save-32x32.png"/>
                <dxb:BarButtonItem Name="txtundo" Content="撤销" KeyGesture="Ctrl+Z" Command="Undo" Glyph="/QueryResource;component/Images/Tool/undo-32x32.png"/>
                <dxb:BarButtonItem Name="txtredo" Content="重做" KeyGesture="Ctrl+Y" Command="Redo" Glyph="/QueryResource;component/Images/Tool/redo-32x32.png" />
                <dxb:BarButtonItem Name="txtformat" Content="格式刷" KeyGesture="Ctrl+R" Command="{StaticResource txtFormat}" Glyph="/QueryResource;component/Images/FormatPainter.gif" />
                <dxb:BarButtonItem Name="txtrun" Content="运行" KeyGesture="F5" Command="{StaticResource runSQL}" Glyph="/QueryResource;component/Images/run.png" />
                <dxr:RibbonGalleryBarItem Name="gTheme" DropDownGalleryInit="OnThemeDropDownGalleryInit">
                    <dxr:RibbonGalleryBarItem.Gallery>
                        <dxb:Gallery MinColCount="1" ColCount="3" RowCount="2" ItemCheckMode="Single" AllowHoverAnimation="True" AllowHoverImages="True" FilterCaption="Themes" IsItemCaptionVisible="False" ItemCaptionHorizontalAlignment="Center" HoverGlyphSize="96,96" ItemClick="OnThemeItemClick">
                            <dxb:Gallery.Groups>
                                <dxb:GalleryItemGroup Caption="Office2007">
                                    <dxb:GalleryItem Caption="Office 2007 Black" Tag="Office2007Black" Glyph="/QueryResource;component/Images/ThemeIcons/Office2007Black_48x48.png"/>
                                    <dxb:GalleryItem Caption="Office 2007 Blue" Tag="Office2007Blue" Glyph="/QueryResource;component/Images/ThemeIcons/Office2007Blue_48x48.png"/>
                                    <dxb:GalleryItem Caption="Office 2007 Silver" Tag="Office2007Silver" Glyph="/QueryResource;component/Images/ThemeIcons/Office2007Silver_48x48.png" IsChecked="True"/>
                                </dxb:GalleryItemGroup>
                                <dxb:GalleryItemGroup Caption="Standard">
                                    <dxb:GalleryItem Caption="Light Gray" Tag="LightGray" Glyph="/QueryResource;component/Images/ThemeIcons/LightGray_48x48.png" />
                                    <dxb:GalleryItem Caption="Deep Blue" Tag="DeepBlue" Glyph="/QueryResource;component/Images/ThemeIcons/DeepBlue_48x48.png"/>
                                </dxb:GalleryItemGroup>
                            </dxb:Gallery.Groups>
                        </dxb:Gallery>
                    </dxr:RibbonGalleryBarItem.Gallery>
                </dxr:RibbonGalleryBarItem>

              
                <dxb:BarButtonItem Name="bFind" Content="查找" Command="Find" Glyph="/QueryResource;component/Images/Tool/Find_16x16.png" LargeGlyph="/QueryResource;component/Images/Tool/Find_32x32.png" KeyGesture="Ctrl+F" />
                <dxb:BarButtonItem Name="bReplace" Content="替换" Command="Replace" Glyph="/QueryResource;component/Images/Tool/Replace-16x16.png" LargeGlyph="/QueryResource;component/Images/Tool/Replace_32x32.png" KeyGesture="Ctrl+H" />
               
                <dxb:BarButtonItem Name="bUpdate" Content="更新" KeyGesture="Ctrl+U" Hint="获取最新版本." LargeGlyph="/QueryResource;component/Images/Update.png" ItemClick="bUpdate_ItemClick"/>

                <dxb:BarStaticItem Name="lbFieldName" Content="字段:" ItemMinWidth="100"/>
                <dxb:BarStaticItem Name="lbIPname" Content="IP:" ItemMinWidth="100"/>
                <dxb:BarStaticItem Name="lbDBname" Content="数据库连接:" ItemMinWidth="100"/>
                <dxb:BarStaticItem Name="lbUserId" Content="当前用户:" ItemMinWidth="100"/>
                <dxb:BarStaticItem Name="lbUpdateInfo" Content="当前版本:" ItemMinWidth="100" Alignment="Far"/>
               
            </dxb:BarManager.Items>
            <dxb:BarManager.Bars>
                <dxb:Bar Caption="Main Menu" IsMainMenu="True" Name="mainMenuBar">
                    <dxb:Bar.DockInfo>
                        <dxb:BarDockInfo ContainerType="Top" />
                    </dxb:Bar.DockInfo>
                    <dxb:Bar.ItemLinks>
                        <dxb:BarItemLink BarItemName="dbcreate" RibbonStyle="Large"/>
                       
                        <dxb:BarItemLinkSeparator />
                        <dxb:BarItemLink BarItemName="fileopen" RibbonStyle="Large"/>
                        <dxb:BarItemLink BarItemName="filesave" RibbonStyle="Large"/>
                        <dxb:BarItemLinkSeparator />
                        <dxb:BarItemLink BarItemName="txtrun" RibbonStyle="Large"/>
                       
                        <dxb:BarButtonItemLink BarItemName="bFind" RibbonStyle="All"/>
                        <dxb:BarButtonItemLink BarItemName="bReplace" RibbonStyle="All"/>
                        <dxb:BarItemLinkSeparator />
                        <dxb:BarButtonItemLink BarItemName="txtundo" RibbonStyle="All"/>
                        <dxb:BarButtonItemLink BarItemName="txtredo" RibbonStyle="All"/>
                        <!--<dxb:BarItemLink BarItemName="gTheme"/>-->
                        <dxb:BarItemLink BarItemName="bUpdate"/>
                    </dxb:Bar.ItemLinks>
                </dxb:Bar>
                <dxb:Bar Caption="Status Bar" IsStatusBar="True" Name="statusBar">
                    <dxb:Bar.DockInfo>
                        <dxb:BarDockInfo ContainerType="Bottom" />
                    </dxb:Bar.DockInfo>
                    <dxb:Bar.ItemLinks>
                        <dxb:BarItemLink BarItemName="lbFieldName" />
                        <dxb:BarItemLink BarItemName="lbIPname" />
                        <dxb:BarItemLink BarItemName="lbDBname" />
                        <dxb:BarItemLink BarItemName="lbUserId" />
                        <dxb:BarItemLink BarItemName="lbUpdateInfo" />
                    </dxb:Bar.ItemLinks>
                </dxb:Bar>
            </dxb:BarManager.Bars>
            <DockPanel Name="dockPanel1">
         
                <dxd:DockLayoutManager x:Name="dockManager" 
                                       DockItemClosed="dockManager_DockItemClosed"
                                       Margin="0,-2,0,0">
                    <dxd:LayoutGroup Orientation="Horizontal" TabHeadersAutoFill="False">
                        <dxd:LayoutGroup Width="2*">
                            <dxd:LayoutPanel Caption="数据源" Width="3*" AllowClose="False" AllowRename="False">
                                <ui:DBTreeViewControl x:Name="dbtreeview"/>
                            </dxd:LayoutPanel>
                        </dxd:LayoutGroup>
                        <dxd:LayoutGroup Width="8*" Orientation="Vertical">
                            <dxd:DocumentGroup Name="documentGroup" Height="7*" Width="7*" ClosePageButtonShowMode="InAllTabPageHeaders">
                                <dxd:DocumentPanel Name="documentSQL" Caption="文档" CaptionImage="/QueryResource;component/Images/Tool/copy-16x16.png" AllowClose="False" AllowRename="False">
                                    <ui:SQLControl x:Name="sqlcontrol" Tag="{Binding ElementName=documentSQL}"></ui:SQLControl>
                                </dxd:DocumentPanel>
                            </dxd:DocumentGroup>
                            <dxd:TabbedGroup Height="3*" SelectedTabIndex="0">
                                <dxd:LayoutPanel Name="documentLog" Caption="日志" Width="7*" AllowClose="False" AllowRename="False">
                                    <ui:LogControl x:Name="logcontrol" ></ui:LogControl>
                                </dxd:LayoutPanel>
                                <dxd:LayoutPanel Name="documentDS" Caption="数据" Width="7*" ShowBorder="True" AllowClose="False" AllowRename="False">
                                    <ui:GridViewControl x:Name="gridviewcontrol" Tag="{Binding ElementName=documentDS}"></ui:GridViewControl>
                                </dxd:LayoutPanel>
                               
                            </dxd:TabbedGroup>
                        </dxd:LayoutGroup>
                    </dxd:LayoutGroup>
                </dxd:DockLayoutManager>
            </DockPanel>
        </dxb:BarManager>
    </Grid>
</dx:DXWindow>
